﻿using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

// Token: 0x020003C2 RID: 962
public class ToggleButton : MonoBehaviour
{
	// Token: 0x17000258 RID: 600
	// (get) Token: 0x06001802 RID: 6146 RVA: 0x0009D478 File Offset: 0x0009B678
	// (set) Token: 0x06001803 RID: 6147 RVA: 0x0009D480 File Offset: 0x0009B680
	public bool Value
	{
		get
		{
			return this.value;
		}
		set
		{
			this.ChangeValue(value, true);
		}
	}

	// Token: 0x17000259 RID: 601
	// (get) Token: 0x06001804 RID: 6148 RVA: 0x0009D48C File Offset: 0x0009B68C
	// (set) Token: 0x06001805 RID: 6149 RVA: 0x0009D494 File Offset: 0x0009B694
	public bool Interactable
	{
		get
		{
			return this.interactable;
		}
		set
		{
			this.ChangeInteractable(value);
		}
	}

	// Token: 0x06001806 RID: 6150 RVA: 0x0009D4A0 File Offset: 0x0009B6A0
	public void Setup(string textOFF, string textON, UnityAction<bool> action)
	{
		this.text_on.text = textON;
		this.text_off.text = textOFF;
		this.action.AddListener(action);
	}

	// Token: 0x06001807 RID: 6151 RVA: 0x0009D4C8 File Offset: 0x0009B6C8
	public void SetText(string textOFF, string textON)
	{
		this.text_on.text = textON;
		this.text_off.text = textOFF;
	}

	// Token: 0x06001808 RID: 6152 RVA: 0x0009D4E4 File Offset: 0x0009B6E4
	public void ActionAddListener(UnityAction<bool> action)
	{
		this.action.AddListener(action);
	}

	// Token: 0x06001809 RID: 6153 RVA: 0x0009D4F4 File Offset: 0x0009B6F4
	private void Awake()
	{
		this.SwitchButton();
		this.button_off.onClick.AddListener(delegate()
		{
			this.OnClick(true);
		});
		this.button_on.onClick.AddListener(delegate()
		{
			this.OnClick(false);
		});
		this.button_on.interactable = this.interactable;
		this.button_off.interactable = this.interactable;
	}

	// Token: 0x0600180A RID: 6154 RVA: 0x0009D564 File Offset: 0x0009B764
	private void Start()
	{
	}

	// Token: 0x0600180B RID: 6155 RVA: 0x0009D568 File Offset: 0x0009B768
	private void Update()
	{
	}

	// Token: 0x0600180C RID: 6156 RVA: 0x0009D56C File Offset: 0x0009B76C
	public void ChangeValue(bool flag, bool invoke)
	{
		if (this.value != flag)
		{
			this.value = flag;
			this.SwitchButton();
			if (invoke && this.action != null)
			{
				this.action.Invoke(flag);
			}
		}
	}

	// Token: 0x0600180D RID: 6157 RVA: 0x0009D5A4 File Offset: 0x0009B7A4
	private void SwitchButton()
	{
		this.button_off.gameObject.SetActive(!this.value);
		this.button_on.gameObject.SetActive(this.value);
	}

	// Token: 0x0600180E RID: 6158 RVA: 0x0009D5D8 File Offset: 0x0009B7D8
	private void OnClick(bool flag)
	{
		this.value = flag;
		this.SwitchButton();
		if (this.action != null)
		{
			this.action.Invoke(flag);
		}
	}

	// Token: 0x0600180F RID: 6159 RVA: 0x0009D600 File Offset: 0x0009B800
	private void ChangeInteractable(bool flag)
	{
		this.interactable = flag;
		this.button_on.interactable = this.interactable;
		this.button_off.interactable = this.interactable;
	}

	// Token: 0x06001810 RID: 6160 RVA: 0x0009D62C File Offset: 0x0009B82C
	public void SetColor(ColorBlock onColor, ColorBlock offColor)
	{
		this.button_on.colors = onColor;
		this.button_off.colors = offColor;
	}

	// Token: 0x04001B67 RID: 7015
	[SerializeField]
	private Button button_on;

	// Token: 0x04001B68 RID: 7016
	[SerializeField]
	private Text text_on;

	// Token: 0x04001B69 RID: 7017
	[SerializeField]
	private Button button_off;

	// Token: 0x04001B6A RID: 7018
	[SerializeField]
	private Text text_off;

	// Token: 0x04001B6B RID: 7019
	public ToggleButton.ToggleButtonEvent action;

	// Token: 0x04001B6C RID: 7020
	[SerializeField]
	private bool value;

	// Token: 0x04001B6D RID: 7021
	[SerializeField]
	private bool interactable = true;

	// Token: 0x020003C3 RID: 963
	[Serializable]
	public class ToggleButtonEvent : UnityEvent<bool>
	{
	}
}
